var map,mposctl,vectors, geojson,markers,selectControl;
var selectedFeature;
//Init
map = new OpenLayers.Map('floor6');
layer = new OpenLayers.Layer.Image(
    "floor6",
    "floor6.jpg",
    new OpenLayers.Bounds(-1091,-282,1091,282),
    new OpenLayers.Size(2182,564)
);
map.addLayer(layer);
map.zoomToMaxExtent();
var featurecollection = {
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_92",
            "properties": {
                "name": "Electronic lab",
                "description": "Lab room for EE students"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1080,
                            260
                        ],
                        [
                            -799,
                            259
                        ],
                        [
                            -801,
                            46
                        ],
                        [
                            -1081,
                            46
                        ],
                        [
                            -1080,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_114",
            "properties": {
                "name": "Communication Lab",
                "description": "lab room for communication"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -1081,
                            43
                        ],
                        [
                            -800,
                            41
                        ],
                        [
                            -801,
                            -172
                        ],
                        [
                            -1081,
                            -173
                        ],
                        [
                            -1081,
                            43
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_136",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -683,
                            260
                        ],
                        [
                            -564,
                            259
                        ],
                        [
                            -564,
                            75
                        ],
                        [
                            -682,
                            74
                        ],
                        [
                            -683,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_158",
            "properties": {
                "name": "Elevator_6",
                "description": "Elevator of Floor 6"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -685,
                            -52
                        ],
                        [
                            -545,
                            -53
                        ],
                        [
                            -544,
                            -166
                        ],
                        [
                            -687,
                            -169
                        ],
                        [
                            -685,
                            -52
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_182",
            "properties": {
                "name": "A.603",
                "description": "Auditorium"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -558,
                            259
                        ],
                        [
                            -378,
                            260
                        ],
                        [
                            -380,
                            73
                        ],
                        [
                            -559,
                            73
                        ],
                        [
                            -558,
                            259
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_219",
            "properties": {
                "name": "Simulation Lab",
                "description": "Lab room for Simulation"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -374,
                            259
                        ],
                        [
                            -196,
                            258
                        ],
                        [
                            -196,
                            74
                        ],
                        [
                            -373,
                            74
                        ],
                        [
                            -374,
                            259
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_241",
            "properties": {
                "name": "Databe lab",
                "description": "Lab room for database for IT students"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -189,
                            260
                        ],
                        [
                            0,
                            258
                        ],
                        [
                            -1,
                            74
                        ],
                        [
                            -189,
                            74
                        ],
                        [
                            -189,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_265",
            "properties": {
                "name": "Computer Networking Lab",
                "description": "Lab room for computer network"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            4,
                            260
                        ],
                        [
                            182,
                            259
                        ],
                        [
                            180,
                            74
                        ],
                        [
                            6,
                            74
                        ],
                        [
                            4,
                            260
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_287",
            "properties": {
                "name": "Operating system Lab",
                "description": "Lab room for operaing system"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            188,
                            261
                        ],
                        [
                            381,
                            261
                        ],
                        [
                            380,
                            74
                        ],
                        [
                            187,
                            74
                        ],
                        [
                            188,
                            261
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_311",
            "properties": {
                "name": "Software engineering Lab",
                "description": "Lab room for software engineering"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            383,
                            262
                        ],
                        [
                            568,
                            261
                        ],
                        [
                            569,
                            73
                        ],
                        [
                            384,
                            74
                        ],
                        [
                            383,
                            262
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_333",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            572,
                            262
                        ],
                        [
                            671,
                            260
                        ],
                        [
                            673,
                            74
                        ],
                        [
                            575,
                            75
                        ],
                        [
                            572,
                            262
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_357",
            "properties": {
                "name": "Department of Electrical engineering",
                "description": "the working office of EE school"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            821,
                            263
                        ],
                        [
                            1087,
                            260
                        ],
                        [
                            1086,
                            40
                        ],
                        [
                            821,
                            40
                        ],
                        [
                            821,
                            263
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_379",
            "properties": {
                "name": "Department of Computer science and Egnineering ",
                "description": "the working office of IT school"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            821,
                            35
                        ],
                        [
                            1085,
                            36
                        ],
                        [
                            1085,
                            -167
                        ],
                        [
                            821,
                            -169
                        ],
                        [
                            821,
                            35
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_403",
            "properties": {
                "name": "Stair_6",
                "description": "Stair of Floor 6"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            672,
                            -178
                        ],
                        [
                            751,
                            -178
                        ],
                        [
                            751,
                            -250
                        ],
                        [
                            674,
                            -251
                        ],
                        [
                            672,
                            -178
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_425",
            "properties": {
                "name": "Elevator_6",
                "description": "Elevator of Floor 6"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            528,
                            -52
                        ],
                        [
                            674,
                            -53
                        ],
                        [
                            675,
                            -169
                        ],
                        [
                            527,
                            -169
                        ],
                        [
                            528,
                            -52
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_447",
            "properties": {
                "name": "WC",
                "description": "Restroom"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            339,
                            -50
                        ],
                        [
                            521,
                            -53
                        ],
                        [
                            522,
                            -171
                        ],
                        [
                            339,
                            -172
                        ],
                        [
                            339,
                            -50
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_471",
            "properties": {
                "name": "Project Administration office",
                "description": "project Admin concerns"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            108,
                            -54
                        ],
                        [
                            334,
                            -54
                        ],
                        [
                            333,
                            -167
                        ],
                        [
                            108,
                            -167
                        ],
                        [
                            108,
                            -54
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_493",
            "properties": {
                "name": "Meeting room of EE school",
                "description": "for meeting and discussion of EE school"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -116,
                            -54
                        ],
                        [
                            103,
                            -53
                        ],
                        [
                            104,
                            -168
                        ],
                        [
                            -116,
                            -169
                        ],
                        [
                            -116,
                            -54
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_517",
            "properties": {
                "name": "Office of media and pubic relations",
                "description": "concerning media-public relations activities"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -331,
                            -53
                        ],
                        [
                            -120,
                            -54
                        ],
                        [
                            -122,
                            -168
                        ],
                        [
                            -331,
                            -169
                        ],
                        [
                            -331,
                            -53
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_539",
            "properties": {
                "name": "Quality management center",
                "description": "concerning the quality"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -541,
                            -52
                        ],
                        [
                            -336,
                            -54
                        ],
                        [
                            -336,
                            -168
                        ],
                        [
                            -540,
                            -167
                        ],
                        [
                            -541,
                            -52
                        ]
                    ]
                ]
            }
        },
        {
            "type": "Feature",
            "id": "OpenLayers.Feature.Vector_576",
            "properties": {
                "name": "Stair_6",
                "description": "Stair of Floor 6"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            -755,
                            -178
                        ],
                        [
                            -689,
                            -179
                        ],
                        [
                            -689,
                            -249
                        ],
                        [
                            -756,
                            -249
                        ],
                        [
                            -755,
                            -178
                        ]
                    ]
                ]
            }
        }
    ]
}
geojson = new OpenLayers.Format.GeoJSON();
vectors = new OpenLayers.Layer.Vector();
selectControl= new OpenLayers.Control.SelectFeature(vectors,
    {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect});
map.addLayer(vectors);
vectors.addFeatures(geojson.read(featurecollection));
map.addControl(selectControl);
selectControl.activate();
function onPopupClose(){selectControl.unselect(selectedFeature);};
function onFeatureSelect(feature){
    selectedFeature = feature;
    popup = new OpenLayers.Popup.FramedCloud(feature.id + "pop", feature.geometry.getBounds().getCenterLonLat(),null,"<div style='font-size:.8em'>Room: " + feature.attributes.name + "<br />Description: " + feature.attributes.description + "</div>",null, true, onPopupClose);
    feature.popup = popup;
    map.addPopup(popup);
}
function onFeatureUnselect(feature){
    map.removePopup(feature.popup);
    feature.popup.destroy();
    feature.popup = null;
}
